<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>


<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

<script type="text/javascript">

      $(function(){
    	  
    	  $("#ss").click(function(){
    		  
    		  var adata={"name":$("#name").val(),
    	                 "password":$("#password").val()			  
    		           };
    		  var data=JSON.stringify(adata);
    		  
    		  $.ajax({
    			  type:"POST",
    			  contentType:"application/json",
    			  dataType:"json",
    			  data:data,
    			  url:"saveStudent.do",
    			  
    			  success:function(data){
    				  
    				  alert("成功");
    				  
    			  },
    			  
    			  error:function(){
    				  
    				  alert("失败");
    			  },
    			  
    			  
    		  });
    		  
    	  });    	  
  
    	  
      });

</script>



<script type="text/javascript">

     $(function(){
    	 
    	  $("#jj").click(function(){
    		 
    	    var adata={"name":$("#name").val(),
    	     		   "password":$("#password").val()
                	 };
    		var data=JSON.stringify(adata);
    		
    		$.ajax({
    			type:"POST",
    			contentType:"application/json",
    			dataType:"json",
    			data:data,
    			url:"getId.do",
    			
    			success:function(data){
    				alert(data.id);
    				document.getElementById('show').value=data.id;
    				
    			     },
    			     
    			error:function(){
    				alert("网络连接失败");
    			}     
    			
    		}); 
    		 
    	  });
    	 
     });
  
</script>






<body>

<h1>咔咔咔咔咔咔咔咔咔咔咔咔咔咔咔咔</h1>


用户:<input type="text" id="name" >
密码:<input type="password" id="password">
<br><br><hr>

显示区<input type="text" id="show">


<button id="ss">注册</button><br/>
<button id="jj">显示id</button>





</body>
</html>